"""
权限管理
"""
from rest_framework.permissions import BasePermission


class BackendPermission(BasePermission):
    def has_permission(self, request, view):
        user = request.user
        try:
            sign_list = [sign.get("sign") for sign in user.role.all().values("sign")]
            if user.is_authenticated and '2' in sign_list or '3' in sign_list:
                return True
            return False
        except Exception as e:
            return False
